Software may be parallelized to permit faster execution, to organize workflow, to provide redundancy, and/or to support distributed processing, for example. Parallel computing environments have been designed in various configurations. Some include a single processor running multiple threads; some include multiple processors running multiple threads. In some multiprocessor configurations, all of the processors are functionally equal, whereas in other configurations some processors differ from other processors by virtue of having different hardware capabilities, different software assignments, or both.
Within a multithreaded environment, a given thread may need an ability to communicate with another thread, an ability to synchronize its own execution with the execution of another thread, or both. Locks are sometimes used for synchronizing threads in multithreaded computing systems, and to help control inter-thread communication. Some systems provide hardware support for locks through atomic instructions, such as a test-and-set atomic instruction which tests whether a lock is free and acquires the lock if it is free, or a compare-and-swap atomic instruction which compares the content of a memory location to a given value and modifies the memory location content if it was the same as the given value.